using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media.Animation;


namespace LayoutPlanning.Converters
{
    public class ExponentialValue : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var pow = parameter as Nullable<double>;
            var number = value as Nullable<double>;
            if (number == null)
                return null;

            if (pow == null)
                pow = 2;


            return Math.Pow(number.Value, 1/pow.Value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var pow = parameter as Nullable<double>;
            var number = value as Nullable<double>;
            if (number == null)
                return null;

            if (pow == null)
                pow = 2;


            return Math.Pow(number.Value, pow.Value);
        }
    }
}